<div
	style="min-height: 300px; padding-bottom: 20px; width: 98%; float: left"
	class="portlet x12">
<div class="portlet-header">
<h4><?php echo $type;?>
<!--<div class="buttonrow" style="float: right; margin-right: 20px;"><a
	href="<?php
	echo base_url ();
	?>admin/gallery/add/<?php echo $type;?>"><input type="button"
	value="Th&#234;m m&#7841;i" class="btn btn-orange"></a></div>

--></h4>
</div>
<!-- .portlet-header -->
<div class="portlet-content">
<table cellpadding="0" cellspacing="0" align="center"
	style="width: 100%;">
	<tr>
		<td style="width: 100%;">
		<table cellpadding="0" cellspacing="0" align="center"
			style="width: 100%;">
			<thead>
				<tr>					
					<th style="width: 70%;">Thumbnail</th>
					<th>Hi&#7875;n th&#7883;</th>
					<th>Ch&#7913;c n&#259;ng</th>					
				</tr>
			</thead>	
	<?php
	if (count ( $list ) > 0) {
		
		?>	
	<?php
		foreach ( $list as $item ) {
			?>	
		<tr>				
			<td style="width: 70%;">
				<img width="286" height="102" alt="<?php echo $type;?>" src="<?php echo base_url (); ?>application/storage/images/<?php echo $item->file_name; ?>">
			</td>
			<td>
				<input <?php if ($type=='Logo'){ ?> type="radio"  <?php } else { ?> type="checkbox" <?php }?>name="active" value="1" <?php if($item->active == '1'){?> checked="checked" <?php } ?> onchange="saveActive(this,'<?php
			echo $item->id;?>','<?php echo $type;?>');">
				
			</td>
			<td>			
				<input type="button" value="Xo&#225;" class="btn btn-red" onclick="del_item('<?php	echo $item->id;	?>','<?php echo $type;?>')">		
			</td>
		</tr>
	<?php
		}
		?>
	<?php
	} else {
		?>			
		<tr class="fontGL row0">
			<td colspan="3"><span style="font-size: 13px;">Kh&#244;ng c&#243; <?php echo $type;?></span></td>
		</tr>
	<?php
	}
	?>
			
		</table>
		</td>
	</tr>
	<tr><td>&nbsp;</td></tr>
	<tr><td>
	<form action="<?php echo base_url (); ?>admin/gallery/add"	method="post" enctype="multipart/form-data">
		<input type="hidden" name="type" value="<?php echo $type;?>" />
		<input type="file" name="img" />
		<input type="submit" name="ok" value="Upload" />
	</form>
	
	</td></tr>
</table>


</div>

</div>
<!--END main-->
<script>


function viewDetail(id){
	window.location="<?php echo base_url();?>admin/posts/detail/"+id;
}
function del_item(id,type){
	
	var store_del = confirm("Xoa hinh anh ?");
	
	if(store_del==true){
		window.location="<?php echo base_url();?>admin/gallery/del/"+type+"/"+id;
	}else{
		return false;
	}		
}
function saveActive(obj,id,type){
	var value=0;
	if(obj.checked==true){
		value=1;
	}
	$.post(
			"<?php
			echo base_url ();
			?>gallery/admin/gallery/saveActive",
			{id : id, type : type, value : value},						
			function(data){				
			}
		);
}
</script>